package com.sprint.controller;

import com.sprint.entities.CommonResult;
import com.sprint.entities.Payment;
import com.sprint.service.PaymentService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.client.ServiceInstance;
import org.springframework.cloud.client.discovery.DiscoveryClient;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;
import java.util.concurrent.TimeUnit;

@Slf4j //打印日志
@RestController
public class PaymentController {

    @Autowired
    private PaymentService paymentService;

    @Value("${server.port}")
    private String ServicePort;
    @GetMapping("/payment/hystrix/{id}")
    public String paymentinfo_ok(@PathVariable("id") Integer id)
    {
        String str = paymentService.paymentinfo_ok(id);
        return str;
    }

    @GetMapping("/payment/hystrix/timeout/{id}")
    public String paymentinfo_timeout(@PathVariable("id") Integer id){
        String s = paymentService.payment_Timeout(id);
        return s;
    }

    @GetMapping("/payment/hystrix/breaker/{id}")
    public String paymentinfo_breaker(@PathVariable("id") Integer id){
        String s = paymentService.paymentCircuitBreaker(id);
        return s;
    }


}
